#include <Wire.h>

void setup() {
  Serial.begin(115200);
  Wire.begin();
  /**
    0x3E:设备地址，0x00:寄存器地址，0x5C：默认频率在86MHZ
    经过实践从0x5C每增加20，频率增加2MHZ
  */
  writeDataToDevice(0x3E, 0x00, 0x84);//调频到90MHZ
}

void writeDataToDevice(int deviceAddress, int registerAddress, int data) {
  Wire.beginTransmission(deviceAddress);
  Wire.write(registerAddress);
  Wire.write(data);
  Wire.endTransmission();
}

int readDataFromDevice(int deviceAddress, int registerAddress) {
  Wire.beginTransmission(deviceAddress);
  Wire.write(registerAddress);
  Wire.endTransmission();

  Wire.requestFrom(deviceAddress, 1);  // 请求读取 1 个字节的数据

  if (Wire.available()) {
    return Wire.read();
  }
  return -1;  // 表示读取失败
}

void loop() {
  // int readValue = readDataFromDevice(0x3E, 0x00);
  // if (readValue!= -1) {
  //   Serial.println(readValue);
  // }
  // delay(1000);
}